import { UILogicParamType } from '../const/ui-logic-param-type';
import { UILogicParamBase } from './ui-logic-param-base';

/**
 * 导航数据参数绑定参数
 *
 * @export
 * @class UILogicViewNavDataParam
 */
export class UILogicViewNavDataParam extends UILogicParamBase {
	/**
	 * Creates an instance of UILogicViewNavDataParam.
	 * @param {*} opts
	 * @memberof UILogicViewNavDataParam
	 */
	public constructor(opts: any) {
		super(opts);
	}

	/**
	 * 初始化
	 *
	 * @protected
	 * @memberof UILogicViewNavDataParam
	 */
	protected init(params: any) {
		this.logicParamType = UILogicParamType.viewNavDataParam;
		this.realValue = this.getViewNavDataParam(params);
	}

	/**
	 * 获取导航数据参数绑定参数
	 *
	 * @private
	 * @param {any} params
	 * @memberof UILogicViewNavDataParam
	 */
	private getViewNavDataParam(params: any) {
		const { actionContext } = params;
		const { viewCtx } = actionContext;
		if (viewCtx && viewCtx['viewNavData']) {
			return viewCtx['viewNavData'];
		}
	}
}
